<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lesson 28</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="root"></div>
</body>

</html>

<script>
    // Mixin  混入
    // 组件 data 优先级高于mixin data 的优先级
    // 生命周期函数，先执行mixin里面的，再执行组件里面的
    // 自定义属性，组件中的属性优先级高于mixin 属性的优先级
    const myMixin = {
        number: 1
    };

    const app = Vue.createApp({
        mixins: [myMixin],
        number: 2,
        template: `
        <div>
            <div>{{this.$options.number}}</div>
        </div>
        `
    });

    app.config.optionMergeStrategies.number = (mixinVal, appValue) => {
        return mixinVal || appValue;
    };
    
    const vm = app.mount("#root");
</script>